home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / c / vbcc / machines / amiga68k / libsrc / stdio / fwrite.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-20  |  886 b   |  30 lines

  1. #include <stdio.h>
  2.  
  3. size_t fwrite(void *ptr,size_t size,size_t nmemb,FILE *f)
  4. {
  5.     size_t total=size*nmemb;char *p=ptr;long result;
  6.     if(!f||!total) return(0);
  7.     if((f->flags&(_WRITEABLE|_READ|_ERR|_EOF))!=_WRITEABLE) return(0);
  8.     f->flags|=_WRITE;
  9.     /*  einfache (ungepufferte) Implementation  */
  10.     fflush(f);
  11.     result=Write(f->filehandle,p,total);
  12.     if(result==-1){f->flags|=_ERR;return(0);}
  13.     return(result/size);
  14.  
  15. /*    if(f->count){
  16.         if(total<=f->count){
  17.             memcpy(f->pointer,p,total);
  18.             f->pointer+=total;f->count-=total;
  19.             return(total);
  20.         }else{
  21.             memcpy(f->pointer,p,f->count);
  22.             total-=f->count;p+=f->count;
  23.             f->count=0;
  24.         }
  25.     }
  26.     result=Read(f->filehandle,p,total);
  27.     if(result==-1){f->flags|=_ERR;return((p-(char *)ptr)/size);}
  28.     return((p+total-(char *)ptr)/size);*/
  29. }
  30.